<?php
namespace app\share\controller;

use \app\share\model\Ping;
use think\Validate;

class PingAddress
{
    public function __construct()
    {
        $this->ping_address = new Ping();
    }
    /**
     * ping域名或者ip接口
     * @param  address   string    ip或者域名
     * @return  array
     */
    public function pingAddress()
    {
        $input = input();
        $validate = new Validate([
            ['address', 'require', 'Ping的地址不存在'],
        ]);
        if(!$validate->check($input))
        {
            return ['code'=>-1001,'msg'=>$validate->getError()];
        }
        return $this->ping_address->pingAddress($input['address']);
    }
}